<template>
	<view style="width: 100%;height: 100%;overflow: hidden;">
			<view class="topback">
				<view class="shouyimoney">
					<text style="color: #000000;font-size: 24px;text-align: left;font-family: PingFangSC-regular">{{money.now_money}}</text>
					<text style="color: #000000;font-size: 12px;text-align: left;font-family: PingFangSC-regular;">余额</text>
					<text style="width: 300px;">充值请前往客服提交信息,零钱不可提现只能用于开通游戏,可以转让给好友</text>
				</view>
			</view>
		
			<view class="contentred">
				<text style="color: rgba(255, 255, 255, 1);font-size: 14px;" @click="tofa">发的红包</text>
				<text style="color: rgba(255, 255, 255, 1);font-size: 14px;" @click="toshou">收到红包</text>
			</view>
			<view class="jilvtBox">
				<view class="jilvt" v-for="(item,index) in list">
					<view class="one">
						<text class="jilvtText">{{item.state}}</text>
						<text class="jilvttime">{{item.add_time}}</text>
					</view>
					<view class="jilvtText">{{item.type == 1 ? '+' : '-'}}{{item.money}}分</view>
				</view>
			</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				money:[],
				list:[]
			}
		},
		onLoad() {
			let array = []
			let token = uni.getStorageSync("token")
			uni.request({
				url: this.G_base + '/api/user/balance',
				method: "GET",
				header: {
					'content-type': 'application/x-www-form-urlencoded',
					'Authori-zation': 'Bearer ' + token
				},
				success: (res) => {
					// console.log(res)
					this.money = res.data.data
				},
			});
			uni.request({
				url: this.G_base + '/api/myincome',
				method: "POST",
				header: {
					'content-type': 'application/x-www-form-urlencoded',
					'Authori-zation': 'Bearer ' + token
				},
				success: (res) => {
					// console.log(res)
					// if(res.data.data.list)
					res.data.data.list.forEach(item=>{
						if(item.state == '抢红包' || item.state == '发红包'){
							array.push(item)
						}
					})
					this.list = array
					// console.log(this.list)
				},
			});
		},
		onNavigationBarButtonTap(e) {
			// console.log(e)
			if(e.float == "right"){
				uni.navigateTo({
					url:'/pages/tixian/chongzhi/chongzhi'
				})
			}
		},
		methods: {
			tofa(){
				let token = uni.getStorageSync("token")
				uni.request({
					url: this.G_base + '/api/myincomeState',
					data:{
						state:3
					},
					method: "POST",
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation': 'Bearer ' + token
					},
					success: (res) => {
						console.log()
						this.list=res.data.data
					},
				});
			},
			toshou(){
				let token = uni.getStorageSync("token")
				uni.request({
					url: this.G_base + '/api/myincomeState',
					data:{
						state:1
					},
					method: "POST",
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation': 'Bearer ' + token
					},
					success: (res) => {
						console.log()
						this.list=res.data.data
					},
				});
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			gojilv() {
				uni.navigateTo({
					url: "../../tixian/chongzhi/chongzhi"
				})
			},
			test() {
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style>
	.contentred text {
		margin-left: 40px;
		margin-right: 40px;
	}
	.contentred {
		width: 89%;
		height: 48px;
		margin: 0 auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		color: #FFFFFF;
		line-height: 20px;
		border-radius: 5px;
		background-color: rgba(255, 37, 37, 1);
		text-align: center;
		margin-bottom: 20px;
	}
	.jilvtBox{
		width: 89%;
		margin: 0 auto;
	}
	.jilvt .one {
		display: flex;
		flex-direction: column;
	}

	.jilvt {
		/* margin: 10px; */
		height: 100upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px solid #f6f6f6;
	}
	.jilvtText{
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		text-align: left;
		font-family: PingFangSC-regular;
	}
	.jilvttime{
		color: #010101;
		font-size: 12px;
		text-align: left;
		font-family: PingFangSC-regular;
	}

	.shouyimoney {
		margin-top: 30px;
		flex-direction: column;
		display: flex;
		justify-content: center;
		align-items: center;

	}

	.shouyimoney text:nth-child(1) {
		margin-bottom: 10px;
	}

	.topback {
		width: 100%;
		height: 150px;
		line-height: 20px;
		/* background: -webkit-linear-gradient(left,#a00000,#e10004,#a00000); */
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		text-align: center;
		font-family: Arial;
		border: 1px solid rgba(255, 255, 255, 0);
	}
</style>
